﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TreeSharp;
using Styx.Combat.CombatRoutine;
using Styx;
using FelMaster.Classes;

namespace FelMaster
{
    public class Blood : TalentBase
    {
        public override string Name
        {
            get { return "Blood by ossirian"; }
        }

        public override float CombatMaxDistance
        {
            get
            {
                return 5f;
            }
        }

        public override Composite Buffs
        {
            get
            {
                return new PrioritySelector(
                    SC.CastSpell("Horn of Winter", a => true, "Horn of Winter")
                );
            }
        }

        public override string KeySpell
        {
            get { return "Heart Strike"; }
        }

        public override Composite SingleRotation
        {
            get
            {
                return new PrioritySelector(
                    SC.CastBuff("Blood Presence", a => true, "Blood Presence"),
                    SC.CastSpell("Bone Shield", a => true, "Bone Shield"),
                    SC.CastSpell("Rune Tap", a => SC.PlayerHasBuff("Will of the Necropolis"), "Rune Tap"),
                    SC.CastSpell("Rune Tap", a => !SC.PlayerHasBuff("Blade Barrier") && Me.HealthPercent < 90, "Rune Tap"),
                    SC.CastSpell("Rune Tap", a => Me.HealthPercent < 90, "Rune Tap"),
                    SC.CastSpell("Blood Tap", a => true, "Blood Tap"),
                    SC.CastBuff("Raise Dead", a => SC.TargetHasDebuff("Blood Plague") && SC.TargetHasDebuff("Frost Fever") && Me.CurrentTarget.CurrentHealth > 1500000 || Me.CurrentTarget.MaxHealth == 1, "Raise Dead"),
                    SC.CastSpell("Mind Freeze", a => Me.GotTarget && Me.CurrentTarget.IsCasting, "Mind Freeze"),
                    SC.CastSpell("Outbreak", a => !SC.TargetHasDebuff("Blood Plague"), "Outbreak"),
                    SC.CastSpell("Outbreak", a => !SC.TargetHasDebuff("Frost Fever"), "Outbreak"),
                    SC.CastSpell("Plague Strike", a => !SC.TargetHasDebuff("Blood Plague"), "Plague Strike"),
                    SC.CastSpell("Icy Touch", a => !SC.TargetHasDebuff("Frost Fever"), "Icy Touch"),
                    //SC.CastSpell("Pestilence", a => SimCraftBase.HowManyMobsNearby(StyxWoW.Me, 16 ) > 2, "Pestilence"),
                    SC.CastSpell("Death Strike", a => Me.HealthPercent < 90, "Death Strike"),
                    SC.CastSpell("Blood Boil", a => SC.PlayerHasBuff("Crimson Scourge"), "Blood Boil"),
                    SC.CastSpell("Icebound Fortitude", a => Me.HealthPercent < 40, "Icebound Fortitude"),
                    SC.CastSpell("Death Pact", a => Me.HealthPercent < 50, "Death Pact"),
                    SC.CastSpell("Anti-Magic Shell", a => Me.HealthPercent < 95, "Anti-Magic Shell"),
                    SC.CastSpell("Dancing Rune Weapon", a => !SC.PlayerHasBuff("Bone Shield") && !SC.PlayerHasBuff("Icebound Fortitude") && !SC.PlayerHasBuff("Vampiric Blood"), "Dancing Rune Weapon"),
                    SC.CastSpell("Vampiric Blood", a => !SC.PlayerHasBuff("Bone Shield") && !SC.PlayerHasBuff("Icebound Fortitude") && !SC.PlayerHasBuff("Dancing Rune Weapon"), "Vampiric Blood"),
                    SC.CastSpell("Blood Boil", a => SC.CountEnnemiesInRange(Me.Location, 16) > 2 && SC.PlayerBuffTimeLeft("Blade Barrier") < 3, "Boil Blood"),
                    SC.CastSpell("Heart Strike", a => SC.PlayerBuffTimeLeft("Blade Barrier") < 3, "Heart Strike"),
                    SC.CastSpell("Heart Strike", a => !SC.PlayerHasBuff("Blade Barrier"), "Heart Strike"),
                    SC.CastSpell("Rune Strike", a => true, "Rune Strike"),
                    SC.CastSpell("Death Strike", a => true, "Death Strike"),
                    SC.CastSpell("Heart Strike", a => true, "Heart Strike"),
                    SC.CastSpell("Empower Rune Weapon", a => true, "Empower Rune Weapon"),
                    SC.CastSpell("Horn of Winter", a => true, "Horn of Winter")
                );
            }
        }

        public override Composite PVPRotation
        {
            get { throw new NotImplementedException(); }
        }

        public override Composite PVERotation
        {
            get { return SingleRotation; }
        }
    }
}
